本系列是阅读《Linux Networking Internals》书籍的总结
《Linux Networking Internals》 是基于Linux解释network的书籍, 文章内容还是不错的.
另推荐一本书《Understanding the Linux Kernel》, 阅读本系列之前更加推荐之前的文章, 关于该文章的记录也会放在博客上.
Critical Data Structures
- struct sk_buff
存放packet的结构体 - struct net_device
linux kernel中指代网络设备的结构体 - struct sock
存放socket信息的结构体
sk_buff
Sock Buffer: sk_buff
包括以下内容:
- Layout
- General
- Feature-specific
- Management functions: skb_put, skb_push, skb_pull, skb_reserve
alloc_skb -> dev_alloc_skb
kfree_skb -> dev_kfree_skb
skb_reserve
net_device
net_device structure include:
- Configuration
- Statistics
- Device status
- List management
- Traffic management
- Feature specific
- Generic
- Function pointers (or VFT)
tips: ifconfig/route 通过 ioctl 系统调用来实现; ip/IPROUTE2 使用Netlink socket 来实现.